/**
 * 修改el-input-number框只能输入整数
 */
export const int = {
  onChange(e: any) {
    const input = e.target
    const txt: any = +input.value
    if (!Number.isInteger(txt)) {
      input.value = Number.parseInt(txt)
    }
  },
  mounted(box: HTMLElement, binding: any) {
    binding.input = box.querySelector('input')
    binding.input?.addEventListener('change', binding.dir.onChange)
  },
  beforeUnmount(_: HTMLElement, binding: any) {
    binding.input?.removeEventListener('change', binding.dir.onChange)
  }
}
